package com.lmh.front;

import com.github.pagehelper.PageInfo;
import com.lmh.entity.Article;
import com.lmh.service.ArticleService;
import com.lmh.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/f/article")
public class FrontArticleController {
    @Autowired
    private ArticleService articleService;

    @GetMapping("/get")
    public Result get(Integer id) {
        Article article = articleService.detail(id);
        return Result.ok(article);
    }

    @GetMapping("/getList")
    public Map<String, Object> getByChannelId(Article article) {
        PageInfo<Article> pageInfo = articleService.query(article);
        return Result.ok(pageInfo);
    }

    @GetMapping("/getTop")
    public Result getTop(Article article) {
        List<Article> list = articleService.top(article);
        System.out.println(list);
        return Result.ok(list);
    }

}
